package com.aaa.controller;

import com.aaa.entity.Products;
import com.aaa.service.ProductsService;
import com.aaa.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ fileName:ProductsController
 * @ description:
 * @ author:Azy
 * @ createTime:2023/4/9 12:48
 * @ version:1.0.0
 */
@RestController
public class ProductsController {
    @Resource
    private ProductsService productsService;

    @GetMapping("queryById/{pid}")
    public Result queryById(@PathVariable String pid){
        return productsService.queryById(pid);
    }

    @PostMapping("queryAll")
    public Result queryAll(){
        return productsService.queryAll();
    }
    @DeleteMapping("deleteById/{pid}")
    public Result deleteById(@PathVariable String pid){
        return productsService.deleteById(pid);
    }
    @PostMapping("insert")
    public Result insert(@RequestBody Products products){
        return productsService.insert(products);
    }

    @PutMapping("update")
    public Result update(@RequestBody  Products products){
        System.out.println(products);
        return productsService.update(products);
    }
}
